import { searchRoute } from "@/utils/utils"
import { useLocation } from "react-router-dom"
import { commonRouterList } from "@/routers/routeList"
import { useSelector } from "react-redux"
import { State } from "@/redux/interface"

/**
 * @description 页面按钮权限 hooks
 */
const useAuthButtons = () => {
    const {pathname} = useLocation()
    console.log(pathname)
    const route = searchRoute(pathname, commonRouterList)
    console.log(route)
    const {authButtons} = useSelector((state:State) => state.auth)
    console.log(authButtons)

    return {
        BUTTONS: authButtons[route?.meta?.key] || {}
    }
}

export default useAuthButtons